
import os
from selenium import webdriver
import time

# 打开浏览驱动器
driver = webdriver.Chrome()
driver.implicitly_wait(3)

# 获取当前目录的selen.html文件
file_path = os.path.join('file:///', os.getcwd(), "selenium.html")
driver.get(file_path)

# 定位元素并操作元素
username_element = driver.find_element_by_name("username")
password_element = driver.find_element_by_name("password")
login_button = driver.find_element_by_id("sub")
username_element.send_keys("rabbit")
password_element.send_keys("love")
login_button.click()
time.sleep(3)

# 获取当前页面的url和标题
print('当前页面的url是：', driver.current_url)
print('当前页面的标题是：', driver.title)
time.sleep(3)

# 关闭浏览器
driver.quit()
